Skip to main content

AWSS3PutObject

Type

command

Summary

Upload an object

Syntax

AWSS3PutObject <pBucket>,<pObject>,<pPayload>,<pFile>,<pCustomHeaders>,<pCallback>

Description

The caller of this command will be sent the callback message on completion with two parameters:

  • the request ID
  • the server response which should be empty
  • an error message if one occurred
note

The message is sent before the tsNet connection is closed so it is possible to access the recieved headers using the tsNetRetrHeaders function

For futher details about this API including values for custom headers see the AWS S3 REST API Documentation

note

If a file parameter is specified a temporary encoded version of the file will be created containing signed file binary chunks before the upload. The temporary file is deleted when the upload is complete. For very large files some consideration will beed to be given to available disk space.

Parameters

NameTypeDescription

pBucket

The name of a bucket

pObject

The name (key) of the object

pPayload

The data of the object. Required if pFile is empty.

pFile

A file path to read the object data directly from. Using this option will avoid having the entire object loaded into memory locally. Required if pPayload is empty.

pCustomHeaders

Use this array to specify additional request headers. For example you may specify a pre-canned ACL by setting the x-amz-acl to one of the following values:

  • "private" : Owner gets FULL_CONTROL. No one else has access rights (default).
  • "public-read" : Owner gets FULL_CONTROL. The AllUsers group ( see Who Is a Grantee?) gets READ access.
  • "public-read-write" : Owner gets FULL_CONTROL. The AllUsers group gets READ and WRITE access. Granting this on a bucket is generally not recommended.
  • "aws-exec-read" : Owner gets FULL_CONTROL. Amazon EC2 gets READ access to GET an Amazon Machine Image (AMI) bundle from Amazon S3.
  • "authenticated-read" : Owner gets FULL_CONTROL. The AuthenticatedUsers group gets READ access.
  • "bucket-owner-read" : Object owner gets FULL_CONTROL. Bucket owner gets READ access. If you specify this canned ACL when creating a bucket, Amazon S3 ignores it.
  • "bucket-owner-full-control" : Both the object owner and the bucket owner get FULL_CONTROL over the object. If you specify this canned ACL when creating a bucket, Amazon S3 ignores it.
  • "log-delivery-write" : The LogDelivery group gets WRITE and READ_ACP permissions on the bucket. For more information on logs, see (Server Access Logging).

pCallback

A command name to be sent on completion with the server reponse.

Examples

local tCustomHeaders
put "public-read" into tCustomHeaders["x-amz-acl"]
AWSS3PutObject "mybucket", "myobject", tData, "", tCustomHeaders, "putObjectCallback"
put it into tRequestID

on putObjectCallback pRequestID, pResult, pError
if pError is not empty then
answer pError
end if
end putObjectCallback

library: tsNet

function: tsNetGetStatus, tsNetRetrHeaders